package com.thingple.uhf;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

/**
 *
 * Created by lism on 2017/7/31.
 */

public class TagInfoReciever extends BroadcastReceiver {

    private InventoryListener listener;

    public TagInfoReciever() {
    }

    @Override
    public void onReceive(Context context, Intent intent) {

        Log.d(getClass().getName() + "#onReceive", "Inventory receiver收到Tag广播");
        Bundle bundle = intent.getExtras();
        String tid = bundle.getString("TID");
        String epc = bundle.getString("EPC");
        String user = bundle.getString("USER");
        if (this.listener != null) {
            this.listener.onInventory(tid, epc, user);
        }
    }

    public void registerListener(InventoryListener listener) {

        this.listener = listener;
    }

    public void clearListener() {

        this.listener = null;
    }
}
